// pages/group/group.js
// var postData = require('group.js');  
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        orgId: '123',
       
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        var orgId = wx.getStorageSync('orgId');
        var openId = wx.getStorageSync('openId');
        this.setData({
            openId: openId,
            orgId: orgId
        });
        console.log("openId" + openId);
        if (openId == '') {
            wx.showModal({
                title: '提示',
                content: '获取授权信息失败',
                showCancel: false
            })
            wx.navigateBack({
                delta: 7,
            })
        }
        wx.showLoading({
            title: '数据加载中'
        });
        that.requestData(openId);
        //请求后台数据
    },
    requestData: function (openId){
      var that = this;
      wx.request({
        url: app.globalData.mpurl + 'group/getMobileList',
        method: "GET",
        data: {
          openId: openId,
          oid: that.data.orgId
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded' // 默认值
        },
        success: function (res) {
          wx.hideLoading();
          res = res.data;
          console.log(res);
          if (res.code == '00') {
            that.setData({ respData: res.data });
          } else {
            wx.showModal({
              title: '提示',
              content: '获取信息失败',
              showCancel: false,
            })
          }
        },
        fail: function (res) {
          wx.hideLoading();
          wx.showModal({
            title: '提示',
            content: "系统异常，请稍候再试",
            showCancel: false
          })
        }
      });
    },
    calling: function (e) {
        var mobileNum = e.currentTarget.dataset.mobile;
        wx.makePhoneCall({
            phoneNumber: mobileNum,
            success: function () {
                console.log("拨打电话成功！")
            },
            fail: function () {
                console.log("拨打电话失败！")
            }
        })
    },
    seeInfo: function (e) {
        var memNum = e.currentTarget.dataset.num;
        var memName = e.currentTarget.dataset.name;
        wx.setStorageSync('memName', memName);
        wx.setStorageSync('memNum', memNum);
            wx.navigateTo({
                url: '../hisInfo/hisInfo',
                success: function (res) { },
                fail: function (res) { },
                complete: function (res) { },
            })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        var orgName = wx.getStorageSync('orgName');
        wx.setNavigationBarTitle({
            title: orgName,
        })
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})